<template>
  <Form ref="formRef" :model="formData" :rules="rules" :label-width="120">
    <FormItem label="设备端口：" prop="port">
      <InputNumber
        v-model="formData.port"
        placeholder="请输入设备端口..."
        style="width:100%;"
      />
    </FormItem>
  </Form>
</template>
<script>
import { generateRules } from '../utils'
export default {
  props: {
    form: {
      type: Object,
      default: new Object()
    }
  },
  data() {
    return {
      formData: {
        port: null
      },
      rules: generateRules()
    }
  },
  methods: {
    validate(callback) {
      this.$refs.formRef.validate(valid => {
        if (valid) {
          const params = {
            formData: Object.assign({}, this.form, this.formData)
          }
          callback(valid, params)
        } else {
          callback(valid)
        }
      })
    },

    resetFields() {
      this.$refs.formRef.resetFields()
      this.formData.port = ''
    }
  }
}
</script>
